package com.zqxq.file.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.servlet.MultipartConfigElement;

@ConfigurationProperties(prefix = "file-config")
@Component
@Data
public class FileConfig {
    //公有目录
    private String file_diskPath_public;
    //私有目录
    private String file_diskPath_private;
    //DNS
    private String image_dns;
    /**
     * 文件上传配置
     * @return
     */
    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //文件最大
        factory.setMaxFileSize("2000KB"); //KB,MB
        /// 设置总上传数据总大小
        factory.setMaxRequestSize("2000KB");
        return factory.createMultipartConfig();
    }
}
